/*
 * @Author: sunzhijun 
 * @Date: 2019-08-16 09:40:23 
 * @Last Modified by: sunzhijun
 * @Last Modified time: 2020-01-09 11:59:57
 */
import { toast } from 'nc-lightapp-front';
export default class TerminationModal{
    constructor(comp) {
        this.comp = comp;
        this.dispatch = this.comp.props.dispatch;
        this.time = this.comp.props.main.defaultTime;
    }
    //选择时间
    changeTime = ( time )=>{
        this.time = time;
    }
    
    //隐藏Modal
    hiddenModal = ()=>{
        const { props } = this.comp;
        this.dispatch({
            type: 'main/update',
            payload: {
                terminationModalVisible: false
            }
        })
    }

    //终止关系
    termination = async ()=>{
        const { props, action } = this.comp;
        const { main, form } = props;
        const { language } = main;
        let bd_psndoc = main.bd_psndoc;
        let hi_psndoc_cert = main.hi_psndoc_cert;
        let hi_psnjob_h = main.hi_psnjob_h;
        let hi_psnorg_h = main.hi_psnorg_h;
        let endDate = form.getFormItemsValue('stopPoi', 'endDate').value;
        if(!form.isCheckNow('stopPoi')){
            return false;
        }
        let res = await this.dispatch({
            type: 'main/setTermination',
            payload: {
                bd_psndoc: bd_psndoc,               //人员基本信息卡片
                endDate: endDate,	                //弹框结束日期	string	
                hi_psndoc_cert:	hi_psndoc_cert,     //身份证件VO	object	
                hi_psnjob_h: hi_psnjob_h,	        //工作信息vo	object	
                hi_psnorg_h: hi_psnorg_h,	        //组织关系vo	object	
                pk_org: main.pk_org	                //主页面人力资源组织主键	string	
            }
        })
        if(res.success){
            this.hiddenModal();
            action.tableAct.getMainTableData();
            toast({color: 'success', content: language['hi6007-000292']}); //终止关系成功
        }
    }
}